<template>
    <div>
        <h1>{{title}}</h1>

        <h3 v-html="content"></h3>
        <div style="margin-top: 5%"></div>
        <el-table :data="enclosureList"
                  @cell-click="downloadFile"
                  style="width: 100%"
                  v-if="enclosureList.length !==0">
            <el-table-column
                    prop="name"
                    label="附件">
            </el-table-column>
            <el-table-column
                    prop="updateDate"
                    label="时间"
                    width="100px">
            </el-table-column>
        </el-table>

        <div v-if="compressFileUrl !== ''" style="margin-top: 5%">
            <span style="word-wrap: break-word;">相关文件下载 ：{{compressFileUrl}}</span>
        </div>

        <h2>{{createDate}}</h2>
    </div>
</template>

<script>
    import util from 'assets/js/util.js'
    import conf from 'assets/js/conf.js'

    export default {
        data() {
            return {
                enclosureList: [],
                title: '',
                content: '',
                createDate: '',
                caseId: 0,
                compressFileUrl: '',
                creditorId: 0
            }
        },

        mounted() {
            this.id =  util.getUrlParam(document.location.href,'id');

            const _self = this;
            util.ajax({
                url: `/message/info`,
                params: {id:this.id},
                success: function (data) {
                    _self.title = data.data.title || '';
                    _self.content = data.data.content || '';
                    _self.compressFileUrl = data.data.compressFileUrl || '';
                    _self.createDate = util.formatDate(data.data.createDate) ;
                    //_self.id = data.data.id;
                        util.ajax({
                            url: '/file/getFileList',
                            params: {},
                            success: function (data) {
                                data.data.forEach(_file => _self.enclosureList.push({
                                    //name: '附件 ' + (_self.enclosureList.length + 1),
                                    name:'附件' + (data.data.enclosureIds),
                                    updateDate: util.formatDate(_file.createDate)
                                }))
                            },
                        });

                },
            });
        },
        methods: {
            downloadFile: function (row, column, cell, event) {
                window.open(conf.baseUrl + '/file/get/'+ row.id + '?type=1')
            },
        }
    }
</script>

<style>
    h1 {
        text-align: center;
        margin: 20px;
        font-size: 25px;
    }

    h3 {
        line-height: 30px;
        margin-top: 10%;
    }

    h2 {
        float: right;
        margin-right: 10%;
        font-size:15px;
    }
</style>
